class AbstractError(Exception):
    def __init__(self, msg):
        self.__msg = msg

    def msg(self):
        return self.__msg


class InvalidArgumentError(AbstractError):
    def __init__(self, msg=None, index=0):
        super().__init__(self, msg)
        self. __index = index

    def index(self):
        return self.__index

    def __str__(self):
        return "args({}) error:{}".format(self.__index, self.msg())

class StdError(AbstractError):
    def __init__(self, code, msg):
        super().__init__(self, msg)
        self.__code = code

    def code(self):
        return self.__code

    def __str__(self):
        return "{}:{}".format(self.code, self.msg())


class DuplicatedKeyError(AbstractError):
    def __init__(self, msg, key):
        super().__init__(self, msg)
        self.__key = key

    def key(self):
        return self.__key

    def __str__(self):
        return "key:[{}] is duplicated, msg:{}".format(self.__key, self.msg())
